/**
* Copyright (c) 2016-2100 yunclouds
*/
package com.yunqian.web;

import com.yunqian.common.CurrentUser;
import com.yunqian.jwt.JwtUser;
import com.yunqian.redot.constant.BooleanStatus;
import com.yunqian.redot.domain.InformationWords;
import com.yunqian.redot.domain.view.InformationWordsDetails;
import com.yunqian.redot.service.InformationWordsDetailsService;
import com.yunqian.redot.service.InformationWordsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.Map;


/**
 * Describe: 咨询留言控制器
 *
 * @author zsy
 * 2018-09-29 15:54:49
 */
 @RestController
 @RequestMapping("/api/informationWords")
public class InformationWordsController {

     @Autowired
     private InformationWordsService informationWordsService;
     @Autowired
     private InformationWordsDetailsService informationWordsDetailsService;

    /**
     * 获取分页
     *
     * @param params
     * @return
     */
    @PostMapping("/pagination")
    public Page<InformationWordsDetails> pagination(@RequestBody Map<String, Object> params) {
        params.put("_filter_eq_asBrilliant", BooleanStatus.YES.getCode());
        return informationWordsDetailsService.pagination(params);
    }

    /**
     * 留言
     *
     * @param informationWords 对象信息
     */
    @PostMapping
    public InformationWords save(@RequestBody @Valid InformationWords informationWords, @CurrentUser JwtUser user) {
        informationWords.setCustomerId(user.getId());
        informationWordsService.save(informationWords);
        return informationWords;
    }

}
